<?php

class McCube_Html_Icon extends McCube_Html_Abstact{

    protected $_src      = '';
    protected $_text     = '';
    protected $_attrsImg = array();

    public function __construct(){

    }

    public function __toString(){
        return $this->render();
    }

    public function img($src, $attrs=array()){
        $this->_src      = $src;
        $this->_attrsImg = $attrs;
        return $this;
    }

    public function a($href, $attrs=array()){
        $this->_attrs += $attrs;
        $this->_attrs['href'] = $href;
        return $this;
    }

    public function onClick($onclick, $attrs=array()){
        $this->_attrs += $attrs;
        $this->_attrs['onclick'] = $onclick;
        return $this;
    }

    public function text($text){
        $this->_text = $text;
        return $this;
    }

    public function render($theme=null){
        return
            '<a'.$this->buildAttrs().'>'
                .McCube_Theme::get($theme)->img($this->_src, $this->_attrsImg)
                .(isset($this->_text) ? ' '.$this->_text : '')
            .'</a>'
        ;
    }

}